# 编码与解码

from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
from Crypto.Random import get_random_bytes
# from configs import key 
key = b'\x91F\xd7\n\x94\x87*[\xbfP\x813\x8d\xa6\x10\xb3'
__aes_cipher=AES.new(key, AES.MODE_ECB)

def encryption(word):
    word = bytes(word,encoding='UTF-8')
    encrypted_data = __aes_cipher.encrypt(pad(word, AES.block_size))
    return encrypted_data

def disencryption(word,type=str,encode='UTF-8'):
    decrypted_data = unpad(__aes_cipher.decrypt(word), AES.block_size)
    return type(decrypted_data,encoding=encode)

if __name__ == '__main__':
    input = '123456'
    a = encryption(input)
    b = disencryption(a)
    print(a)
    print(b) 